import React from 'react';
import * as asyncLoad from '../util/asyncLoad';
import { fnaFiles } from '../constants/fileConfig';
import Loading from './Loading';

export default class WeaFna extends React.Component{
    constructor(){
        super();
        this.state = {
            hasLoad: false
        };
    }
    componentDidMount(){
        const init = () =>{
            this.setState({hasLoad:true});
        }
        asyncLoad.asyncLoadModule('fna', fnaFiles, init);
    }
    render(){
        const { hasLoad } = this.state;
        if(hasLoad){
            const { WeaFna } = window.weaFnaSpecial;
            return (
                <WeaFna ecId={`${this && this.props && this.props.ecId || ''}_WeaFna@h6qoi0`} {...this.props} />
            )
        }else{
            return (<Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@ot92tc`} />);
        }
    }
}